package com.nciae.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nciae.po.OrderDetail;
import com.nciae.dao.OrderDetailMapper;
import com.nciae.po.OrderMaster;
import com.nciae.service.IOrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nciae.service.IOrderMasterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单详情表 服务实现类
 * </p>
 *
 * @author YangChen
 * @since 2021-10-14
 */
@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements IOrderDetailService {


    @Autowired
    private IOrderMasterService orderMasterService;

    @Override
    public List<OrderDetail> findAll() {
        return baseMapper.selectList(null);
    }

    @Override
    public List<OrderDetail> findByOrderId(String orderId) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("order_id", orderId);
        List<OrderDetail> orderDetailList = baseMapper.selectList(wrapper);
        return orderDetailList;
    }

    @Override
    public OrderDetail insert(OrderDetail orderDetail) {
        baseMapper.insert(orderDetail);
        return orderDetail;
    }
}
